package com.zb.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zb.entity.ZjCodePrintTemplateComponentDataType;
import com.zb.mapper.ZjCodePrintTemplateComponentDataTypeMapper;
import com.zb.service.ZjCodePrintTemplateComponentDataTypeService;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * <p>
 * 编码打印模板组件数据类型表 服务实现类
 * </p>
 *
 * @author WEN
 * @since 2023-09-07
 */
@Service
public class ZjCodePrintTemplateComponentDataTypeServiceImpl extends ServiceImpl<ZjCodePrintTemplateComponentDataTypeMapper, ZjCodePrintTemplateComponentDataType> implements ZjCodePrintTemplateComponentDataTypeService {

    // 根据编码打印模板组件表ID查询数据类型信息
    @Override
    public List<ZjCodePrintTemplateComponentDataType> getByPrintTemplateComponentIds(List<Long> printTemplateComponentIds) {
        if (null == printTemplateComponentIds || printTemplateComponentIds.isEmpty()) {
            return new ArrayList<>();
        }
        QueryWrapper<ZjCodePrintTemplateComponentDataType> wrapper = new QueryWrapper<>();
        wrapper.select("id", "print_template_component_id", "category", "val");
        wrapper.in("print_template_component_id", printTemplateComponentIds);
        return this.list(wrapper);
    }

    @Override
    public void deleteByPrintTemplateComponentIds(List<Long> printTemplateComponentIds) {
        if (null == printTemplateComponentIds || printTemplateComponentIds.isEmpty()) {
            return;
        }
        QueryWrapper<ZjCodePrintTemplateComponentDataType> wrapper = new QueryWrapper<>();
        wrapper.in("print_template_component_id", printTemplateComponentIds);
        this.remove(wrapper);
    }
}
